<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Kea2测试报告 - {{ timestamp }}</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary-color: #4361ee;
            --secondary-color: #3f37c9;
            --success-color: #4ade80;
            --error-color: #f87171;
            --warning-color: #eb9d16;
            --text-color: #1f2937;
            --text-light: #6b7280;
            --bg-color: #f9fafb;
            --card-bg: #ffffff;
            --border-color: #e5e7eb;
            --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
            --border-radius: 0.5rem;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: var(--bg-color);
            color: var(--text-color);
            line-height: 1.6;
            padding: 0;
            margin: 0;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0;
        }
        
        .header {
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            color: white;
            padding: 2rem;
            border-radius: 0;
            margin-bottom: 2rem;
            box-shadow: var(--shadow);
            position: relative;
            overflow: hidden;
        }
        
        .header::before {
            content: '';
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(rgba(255, 255, 255, 0.1), transparent);
            transform: rotate(30deg);
            z-index: 1;
        }
        
        .header-content {
            position: relative;
            z-index: 2;
        }
        
        .header h1 {
            margin: 0;
            font-weight: 600;
            font-size: 2.2rem;
            margin-bottom: 0.5rem;
        }
        
        .header p {
            margin: 0;
            opacity: 0.9;
            font-size: 1rem;
        }
        
        .header-advantages {
            margin-top: 1.5rem;
            padding-top: 1rem;
            border-top: 1px solid rgba(255, 255, 255, 0.2);
        }
        
        .header-advantages h2 {
            color: white;
            font-size: 1.3rem;
            margin-bottom: 1rem;
            border-bottom: none;
            padding-bottom: 0;
        }
        
        .header-advantages-list {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }
        
        .header-advantage-item {
            color: rgba(255, 255, 255, 0.9);
            font-size: 0.95rem;
            font-weight: 500;
        }
        
        .header-advantage-item::before {
            content: '•';
            margin-right: 0.5rem;
            color: rgba(255, 255, 255, 0.7);
        }
        
        .main-content {
            padding: 0 2rem 2rem;
        }
        
        .card {
            background-color: var(--card-bg);
            border-radius: var(--border-radius);
            box-shadow: var(--shadow);
            padding: 1.5rem;
            margin-bottom: 1.5rem;
            border: 1px solid var(--border-color);
            transition: transform 0.2s, box-shadow 0.2s;
        }
        
        .card:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 12px -2px rgba(0, 0, 0, 0.12), 0 4px 6px -1px rgba(0, 0, 0, 0.07);
        }
        
        h2 {
            font-weight: 600;
            color: var(--primary-color);
            font-size: 1.5rem;
            margin-bottom: 1rem;
            padding-bottom: 0.5rem;
            border-bottom: 2px solid var(--border-color);
            display: flex;
            align-items: center;
        }
        
        h2 i {
            margin-right: 0.5rem;
        }
        
        h3 {
            font-weight: 500;
            font-size: 1.2rem;
            margin-bottom: 0.75rem;
            color: var(--text-color);
        }
        
        .summary-stats {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 1rem;
            margin-top: 1rem;
        }
        
        .stat-card {
            padding: 1rem;
            border-radius: var(--border-radius);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            text-align: center;
            background-color: rgba(255, 255, 255, 0.8);
            border: 1px solid var(--border-color);
        }
        
        .stat-value {
            font-size: 1.8rem;
            font-weight: 600;
            margin-bottom: 0.5rem;
            color: var(--primary-color);
        }
        
        .stat-label {
            font-size: 0.875rem;
            color: var(--text-light);
        }
        
        .device-info {
            background-color: rgba(67, 97, 238, 0.05);
            padding: 1rem;
            border-radius: var(--border-radius);
            margin-bottom: 1.5rem;
            border-left: 4px solid var(--primary-color);
        }
        
        .test-info {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 1.5rem;
            margin-top: 1rem;
        }
        
        .test-info-item {
            background-color: rgba(67, 97, 238, 0.03);
            padding: 1.25rem;
            border-radius: var(--border-radius);
            border: 1px solid rgba(67, 97, 238, 0.1);
            transition: all 0.2s ease;
        }
        
        .test-info-item:hover {
            background-color: rgba(67, 97, 238, 0.08);
            transform: translateY(-2px);
            box-shadow: var(--shadow);
        }
        
        .test-info-item h4 {
            color: var(--primary-color);
            font-size: 0.9rem;
            font-weight: 600;
            margin-bottom: 0.5rem;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            display: flex;
            align-items: center;
        }
        
        .test-info-item h4 i {
            margin-right: 0.5rem;
            font-size: 1rem;
        }
        
        .test-info-item .value {
            font-size: 1.1rem;
            font-weight: 500;
            color: var(--text-color);
            word-break: break-word;
        }
        
        .test-info-item .duration-value {
            font-size: 1.3rem;
            font-weight: 600;
            color: var(--primary-color);
        }
        
        .advantages-container {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
        }
        
        .advantage-item {
            display: flex;
            align-items: flex-start;
            gap: 1rem;
            padding: 1.5rem;
            background: linear-gradient(135deg, rgba(67, 97, 238, 0.05), rgba(63, 55, 201, 0.03));
            border-radius: var(--border-radius);
            border-left: 4px solid var(--primary-color);
            transition: transform 0.2s, box-shadow 0.2s;
        }
        
        .advantage-item:hover {
            transform: translateX(5px);
            box-shadow: 0 4px 8px rgba(67, 97, 238, 0.15);
        }
        
        .advantage-icon {
            flex-shrink: 0;
            width: 3rem;
            height: 3rem;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
            color: white;
            border-radius: 50%;
            font-size: 1.2rem;
        }
        
        .advantage-content h3 {
            margin: 0 0 0.5rem 0;
            color: var(--primary-color);
            font-size: 1.1rem;
            font-weight: 600;
        }
        
        .advantage-content p {
            margin: 0;
            color: var(--text-color);
            line-height: 1.5;
        }
        
        .error-msg {
            background-color: rgba(248, 113, 113, 0.1);
            padding: 1rem;
            border-radius: var(--border-radius);
            margin-bottom: 1.5rem;
            border-left: 4px solid var(--error-color);
        }
        
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 1.5rem;
            border-radius: var(--border-radius);
            overflow: hidden;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            font-size: 0.95rem;
        }
        
        th, td {
            padding: 0.75rem 1rem;
            text-align: left;
        }
        
        th {
            background-color: rgba(67, 97, 238, 0.1);
            color: var(--primary-color);
            font-weight: 600;
            text-transform: uppercase;
            font-size: 0.75rem;
            letter-spacing: 0.05em;
        }
        
        tr:nth-child(even) {
            background-color: rgba(0, 0, 0, 0.02);
        }
        
        tr:hover {
            background-color: rgba(67, 97, 238, 0.05);
        }
        
        .success {
            color: var(--success-color);
            font-weight: 600;
            display: flex;
            align-items: center;
        }
        
        .success::before {
            content: '•';
            font-size: 1.5rem;
            margin-right: 0.25rem;
        }
        
        .failure {
            color: var(--error-color);
            font-weight: 600;
            display: flex;
            align-items: center;
        }
        
        .failure::before {
            content: '•';
            font-size: 1.5rem;
            margin-right: 0.25rem;
        }

        .warning {
            color: var(--warning-color);
            font-weight: 600;
            display: flex;
            align-items: center;
        }
        
        .warning::before {
            content: '•';
            font-size: 1.5rem;
            margin-right: 0.25rem;
        }
        
        .screenshots {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 1.5rem;
        }
        
        .screenshot {
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            overflow: hidden;
            box-shadow: var(--shadow);
            transition: transform 0.2s;
            background-color: white;
        }
        
        .screenshot:hover {
            transform: scale(1.02);
        }
        
        .screenshot-img-container {
            position: relative;
            overflow: hidden;
            min-height: 200px;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 1rem;
            background-color: rgba(0,0,0,0.02);
        }
        
        .screenshot img {
            max-width: 100%;
            height: auto;
            display: block;
            transition: transform 0.3s;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        
        .screenshot:hover img {
            transform: scale(1.02);
        }
        
        .screenshot-info {
            padding: 1rem;
            border-top: 1px solid var(--border-color);
        }
        
        .screenshot-info p {
            margin: 0;
            font-size: 0.9rem;
            word-wrap: break-word;
            overflow-wrap: break-word;
        }
        
        .screenshot-info .prop-name {
            font-weight: 600;
            color: var(--primary-color);
            margin-bottom: 0.25rem;
            line-height: 1.4;
            word-break: break-all;
            white-space: normal;
            min-height: 2.5rem;
            display: -webkit-box;
            -webkit-box-orient: vertical;
        }
        
        .screenshot-info .timestamp {
            color: var(--text-light);
            font-size: 0.8rem;
            margin-top: 0.5rem;
        }
        
        .empty-message {
            padding: 2rem;
            text-align: center;
            color: var(--text-light);
            font-style: italic;
            background-color: rgba(0, 0, 0, 0.02);
            border-radius: var(--border-radius);
        }
        
        footer {
            text-align: center;
            padding: 2rem;
            color: var(--text-light);
            font-size: 0.875rem;
            border-top: 1px solid var(--border-color);
            margin-top: 2rem;
        }
        
        @media (max-width: 768px) {
            .header {
                padding: 1.5rem;
            }
            
            .header h1 {
                font-size: 1.8rem;
            }
            
            .header-advantages h2 {
                font-size: 1.1rem;
            }
            
            .header-advantage-item {
                font-size: 0.9rem;
            }
            
            .main-content {
                padding: 0 1rem 1rem;
            }
            
            .summary-stats {
                grid-template-columns: repeat(2, 1fr);
            }
            
            .test-info {
                grid-template-columns: 1fr;
                gap: 1rem;
            }
            
            .stat-card {
                padding: 1rem;
            }
            
            .screenshot-img-container {
                padding-top: 75%; /* 4:3 aspect ratio for mobile */
            }
        }
        
        @media (max-width: 480px) {
            th, td {
                padding: 0.5rem;
                font-size: 0.8rem;
            }
            
            .screenshots {
                grid-template-columns: 1fr;
            }
            
            .summary-stats {
                grid-template-columns: 1fr;
            }
            
            .test-info {
                grid-template-columns: 1fr;
                gap: 0.75rem;
            }
            
            .test-info-item {
                padding: 1rem;
            }
        }
        
        /* Animation for cards */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        .card {
            animation: fadeIn 0.3s ease-out forwards;
        }
        
        .card:nth-child(2) {
            animation-delay: 0.1s;
        }
        
        .card:nth-child(3) {
            animation-delay: 0.2s;
        }
        
        /* Fix for the linter errors - replace dynamic inline styles with separate CSS classes */
        .value-success {
            color: var(--success-color);
        }
        
        .value-error {
            color: var(--error-color);
        }
    </style>
</head>
<body>
    <div class="container">
        <header class="header">
            <div class="header-content">
                <h1>Kea2测试报告</h1>
                <p>生成时间: {{ generation_time }}</p>
                
                <div class="header-advantages">
                    <h2><i class="fas fa-star"></i> 基于性质的测试框架优势</h2>
                    <div class="header-advantages-list">
                        <div class="header-advantage-item">支持通过DSL自定义检测场景</div>
                        <div class="header-advantage-item">提升体检工具自动遍历页面的效率和相关性</div>
                        <div class="header-advantage-item">支持自定义自动断言发现深层次功能Bug</div>
                    </div>
                </div>
            </div>
        </header>
        
        <div class="main-content">
            <div class="card">
                <h2><i class="fas fa-info-circle"></i> 测试信息</h2>
                <div class="test-info">
                    <div class="test-info-item">
                        <h4><i class="fas fa-mobile-alt"></i> 设备信息</h4>
                        <div class="value">
                            {% if device_info and device_info.sn %}
                                {{ device_info.sn }}
                            {% else %}
                                未获取到设备信息
                            {% endif %}
                        </div>
                    </div>
                    
                    <div class="test-info-item">
                        <h4><i class="fas fa-clock"></i> 测试时长</h4>
                        <div class="{% if test_duration %}duration-value{% else %}value{% endif %}">
                            {% if test_duration %}
                                {{ test_duration.formatted }}
                            {% else %}
                                测试时长统计中...
                            {% endif %}
                        </div>
                    </div>
                    
                    <div class="test-info-item">
                        <h4><i class="fas fa-mobile-screen-button"></i> 测试应用</h4>
                        <div class="value">
                            {% if test_app %}
                                {{ test_app }}
                            {% else %}
                                com.hmosworld.wayne
                            {% endif %}
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="card">
                <h2><i class="fas fa-chart-pie"></i> 测试摘要</h2>
                <div class="summary-stats">
                    <div class="stat-card">
                        <div class="stat-value">{{ total_stats.total_properties if total_stats else results|length }}</div>
                        <div class="stat-label">总性质数量</div>
                    </div>
                    {% if total_stats %}
                    <div class="stat-card">
                        <div class="stat-value {% if total_stats.executed_properties > 0 %}value-success{% else %}value-error{% endif %}">
                            {{ total_stats.executed_properties }}
                        </div>
                        <div class="stat-label">执行性质数量</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value {% if total_stats.failed_properties > 0 %}value-error{% else %}value-success{% endif %}">
                            {{ total_stats.failed_properties }}
                        </div>
                        <div class="stat-label">执行中断性质数量</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value {% if total_stats.error_properties > 0 %}value-error{% else %}value-success{% endif %}">
                            {{ total_stats.error_properties }}
                        </div>
                        <div class="stat-label">应用缺陷数量</div>
                    </div>
                    {% else %}
                    <div class="stat-card">
                        <div class="stat-value value-success">0</div>
                        <div class="stat-label">执行性质数量</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value value-success">0</div>
                        <div class="stat-label">执行中断性质数量</div>
                    </div>
                    <div class="stat-card">
                        <div class="stat-value value-success">0</div>
                        <div class="stat-label">应用缺陷数量</div>
                    </div>
                    {% endif %}
                </div>
            </div>
            
            {% if error_message %}
            <div class="card">
                <h2><i class="fas fa-exclamation-triangle"></i> 错误信息</h2>
                <div class="error-msg">
                    <p>{{ error_message }}</p>
                </div>
            </div>
            {% endif %}
            
            <div class="card">
                <h2><i class="fas fa-tasks"></i> 性质执行结果</h2>
                {% if results %}
                <div class="table-responsive">
                    <table>
                        <thead>
                            <tr>
                                <th>性质名称</th>
                                <th>前置条件满足次数</th>
                                <th>执行次数</th>
                                <th>失败次数</th>
                                <th>错误次数</th>
                                <th>状态</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for prop_name, stats in results.items() %}
                            <tr>
                                <td>{{ prop_name }}</td>
                                <td>{{ stats.precond_satisfied|default(0) }}</td>
                                <td>{{ stats.executed|default(0) }}</td>
                                <td>{{ stats.fail|default(0) }}</td>
                                <td>{{ stats.error|default(0) }}</td>
                                <td class="{% if stats.executed|default(0) == 0 %}warning{% elif stats.fail|default(0) == 0 and stats.error|default(0) == 0 %}success{% else %}failure{% endif %}">
                                    {% if stats.executed|default(0) == 0 %}未被执行到{% elif stats.fail|default(0) == 0 and stats.error|default(0) == 0 %}通过{% else %}失败{% endif %}
                                </td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
                {% else %}
                <div class="empty-message">
                    <p>暂无测试结果数据</p>
                </div>
                {% endif %}
            </div>
            
            <div class="card">
                <h2><i class="fas fa-images"></i> 错误截图</h2>
                {% if screenshots %}
                <div class="screenshots">
                    {% for screenshot in screenshots %}
                    <div class="screenshot">
                        <div class="screenshot-img-container">
                            <img src="screenshots/{{ screenshot.filename }}" alt="{{ screenshot.filename }}">
                        </div>
                        <div class="screenshot-info">
                            <p class="prop-name">{{ screenshot.prop_name }}</p>
                            {% if screenshot.timestamp %}
                            <p class="timestamp"><i class="far fa-clock"></i> {{ screenshot.timestamp }}</p>
                            {% endif %}
                        </div>
                    </div>
                    {% endfor %}
                </div>
                {% else %}
                <div class="empty-message">
                    <p>暂无错误截图</p>
                </div>
                {% endif %}
            </div>
        </div>
        
        <footer>
            <p>由Kea2测试框架生成</p>
        </footer>
    </div>
</body>
</html> 